<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">

    <title>My JSP 'planDaily.jsp' starting page</title>

	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<jsp:include page="../index.jsp"></jsp:include>
  </head>

  <body>
  	<h3>[ 休暇一覧 ]</h3>

    <s:url id="before" value="/plan/planDaily.action">
    	<s:param name="currentYear">${currentYear}</s:param>
    	<s:param name="currentMonth">${currentMonth-1}</s:param>
    	<s:param name="currentDate">1</s:param>
	</s:url>
	<s:url id="next" value="/plan/planDaily.action">
    	<s:param name="currentYear">${currentYear}</s:param>
    	<s:param name="currentMonth">${currentMonth+1}</s:param>
    	<s:param name="currentDate">1</s:param>
	</s:url>
	<s:url id="beforeyear" value="/plan/planDaily.action">
    	<s:param name="currentYear">${currentYear-1}</s:param>
    	<s:param name="currentMonth">${currentMonth+11}</s:param>
    	<s:param name="currentDate">1</s:param>
	</s:url>
	<s:url id="nextyear" value="/plan/planDaily.action">
    	<s:param name="currentYear">${currentYear+1}</s:param>
    	<s:param name="currentMonth">${currentMonth-11}</s:param>
    	<s:param name="currentDate">1</s:param>
	</s:url>




    <table border="1" cellspacing="0">
    <tbody>
    <tr>
    	<td align="center">
    	<s:if test="%{#request.currentMonth == 1}">
    	<s:a href="%{#beforeyear}"><</s:a>
    	</s:if>
    	<s:else>
    	<s:a href="%{#before}"><</s:a>
    	</s:else>
    	</td>
    	<td align="center" colspan="5">
    	<b>${currentYear}년 ${currentMonth}월</b>
    	</td>
    	<td align="center">
    	<s:if test="%{#request.currentMonth == 12}">
    	<s:a href="%{#nextyear}">></s:a>
    	</s:if>
    	<s:else>
    	<s:a href="%{#next}">></s:a>
    	</s:else>
    	</td>

    </tr>
    <tr>
    	<td align="center">일</td>
    	<td align="center">월</td>
    	<td align="center">화</td>
    	<td align="center">수</td>
    	<td align="center">목</td>
    	<td align="center">금</td>
    	<td align="center">토</td>

    </tr>
    <tr>
    <s:iterator id="counter" value="calendar" status="status">
      	<td align="center" style="width: 30; height: 30;">

      	<s:url id="navigator" value="/plan/planDaily.action">
    		<s:param name="currentYear">${currentYear}</s:param>
    		<s:param name="currentMonth">${currentMonth}</s:param>
    		<s:param name="currentDate">${counter}</s:param>
		</s:url>

		<s:url id="tolastmonth" value="/plan/planDaily.action">
    		<s:param name="currentYear">${currentYear}</s:param>
    		<s:param name="currentMonth">${currentMonth-1}</s:param>
    		<s:param name="currentDate">${counter}</s:param>
		</s:url>

		<s:url id="tonextmonth" value="/plan/planDaily.action">
    		<s:param name="currentYear">${currentYear}</s:param>
    		<s:param name="currentMonth">${currentMonth+1}</s:param>
    		<s:param name="currentDate">${counter}</s:param>
		</s:url>

		<s:url id="tolastyear" value="/plan/planDaily.action">
    		<s:param name="currentYear">${currentYear-1}</s:param>
    		<s:param name="currentMonth">${currentMonth+11}</s:param>
    		<s:param name="currentDate">${counter}</s:param>
		</s:url>

		<s:url id="tonextyear" value="/plan/planDaily.action">
    		<s:param name="currentYear">${currentYear+1}</s:param>
    		<s:param name="currentMonth">${currentMonth-11}</s:param>
    		<s:param name="currentDate">${counter}</s:param>
		</s:url>


    	<s:if test="#status.index < #request.startofmonth">
			<s:if test="%{#request.currentMonth == 1}">
    		<s:a href="%{#tolastyear}"><font size="4"><s:property/></font></s:a>
    		</s:if>
			<s:else>
			<s:a href="%{#tolastmonth}"><font size="4"><s:property/></font></s:a>
			</s:else>
		</s:if>
		<s:elseif test="#status.index > #request.endofmonth">
			<s:if test="%{#request.currentMonth == 12}">
    		<s:a href="%{#tonextyear}"><font size="4"><s:property/></font></s:a>
    		</s:if>
			<s:else>
			<s:a href="%{#tonextmonth}"><font size="4"><s:property/></font></s:a>
			</s:else>
		</s:elseif>
		<s:else>
      	<s:a href="%{#navigator}"><font size="4"><s:property/></font></s:a>
       	</s:else>

       	</td>
    	<s:if test="(#status.index+1)%7 == 0"></tr><tr></s:if>
    </s:iterator>

    </tr>
   	</tbody>
    </table>

    <h4>${currentMonth }월 ${currentDate }일</h4>
    <s:if test="%{#request.planlist.size() != 0}">
    <table>
    <tbody>
    <tr>
    <td align="center" style="width: 300; background-color: efefef;">기간</td>
    <td align="center" style="width: 150; background-color: efefef;">제목</td>
    </tr>
    <tr>
    	<s:iterator value="planlist">
    	<td align="center">
    	<s:property value="startdate"/> - <s:property value="enddate"/>
		</td>
    	<td align="center">
    	<a href="<s:url value="/plan/planRead.action?num="/><s:property value="num"/>">
    	<s:property value="title"/></a>
    	</td>
    	</tr>
    	<tr>
    	</s:iterator>
    </tr>
    </tbody>
    </table>

    </s:if>
    <s:else><h5>일정이 없습니다.</h5></s:else>
  </body>
</html>
